<#assign base=request.contextPath />
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>电子转换给卡转帐</title>
    <link rel="stylesheet" href="${base}/resources/plug/bootstap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="${base}/resources/css/zf/zf-common.css" />
    <link rel="stylesheet" href="${base}/resources/plug/jquery/toast/css/jquery.toast.css" />
    <link rel="stylesheet" href="${base}/resources/css/ka/ka-recharge.css" />
    <link rel="stylesheet" href="${base}/resources/css/ka/ka-account.css" />

</head>

<body>
    <header class="con-header">
        <a href="javascript:history.go(-1)">
            <i class="con-back"></i>
            <h1>转卡账户</h1>
        </a>
    </header>
    <div class="container">
        <div class="car-acccon">

            <div class="car-acccon-je row">
                <div class="col-xs-5">
                    <p>电子账户余额</p>
                    <span id="eaccBalance">${wxResp.data.cardInfos[0].eaccInfos[0].balance!'0.00'}元</span>
                </div>
                <div class="col-xs-7">
                    <p>待写卡金额</p>
                    <span>${wxResp.data.cardInfos[0].unsettle_amount!'0.00'}元</span>
                </div>
            </div>
			<!--注意：当待写卡金额为0时，没有下面这条提示块-->
			 <#if wxResp.data.cardInfos[0].unsettle_amount ??>
            <div class="con-tip">
                <i class="tip-img">i</i>
                <span class="tip-tetle">您有${wxResp.data.cardInfos[0].unsettle_amount!'0.00'}元转账金额需要到自助机上领取。</span>
            </div>
			<!--注意：当待写卡金额为0时，没有上面这条提示块-->
			</#if>
        </div>
        <div class="form-list">
            <p>转入一卡通账户</p>
            <form class="form-horizontal">
                <div class="form-group icon-tzjt x-xian">
                    <label for="inputPassword3" class="col-xs-3 control-label">校一卡通</label>
                    <div class="col-xs-9">
                    	<span id="account-change" class="set-change">${wxResp.data.cardInfos[0].account!''}</span>
                    	<input type="hidden" value="" id="checked_card_id" />
                    	<div id="rollinAccs" style="display: none;"><#list wxResp.data.cardInfos  as card>${card.account},</#list></div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="inputPassword3" class="col-xs-3 control-label">转账金额</label>
                    <div class="col-xs-9">
                        <input type="number" class="form-control" id="amount" placeholder="请输入金额" >
                    </div>
                </div>
            </form>
        </div>
        <div class="con-button">
            <input id="btn" type="button" type="button" onclick="transferSubmit();" class="button log-btn con-btn btn-hui smart-container-sure-btn" value="确认转账" />
        </div>
       
        <div class="con-gstip">
            <blockquote>
                <p>温馨提示</p>
            </blockquote>
            <span>转账后需要到任意的POS或者自助机上领取才能使用。</span>
        </div>
        
    </div>

    <div class="smart-screen-mask"></div>
</body>
<script type="text/javascript" src="${base}/resources/plug/jquery/jquery.min.js"></script>
<script type="text/javascript" src="${base}/resources/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/plug/jquery/toast/js/jquery.toast.js"></script>
<script type="text/javascript">
$("#account-change").on("click",function(){
	var cards = $("#rollinAccs").text();
	cards = cards.substring(0,cards.length -1);
	var arr = cards.split(",");
//	var arr = ["卡1","卡2","卡3"];
	if(arr.length > 1){
		smartObj.accountChange(arr);
	}
})

function verifyAmount(val){
	if(val == ''){
		smartObj.tips("金额不能为空");
		return;
	}
	var reg = /^\+?[1-9][0-9]*$/;//200. 的时候，默认去掉了.
	if(!reg.test(val)) {
		smartObj.tips("金额需为整数");
		$("#amount").val('');
		return;
	}//电子账户余额
	var dAccAmount = $("#eaccBalance").text();
	dAccAmount =dAccAmount.split(".")[0];//获取电子账户余额整数
	if(parseInt(val) > parseInt(dAccAmount)){//js比较数字大小
		smartObj.tips("电子账户余额不足"+val+".00元");
		$("#amount").val('');
		return;
	}
	return true;
}

function transferSubmit(){
	var amount = $("#amount").val();
	var bool = verifyAmount(amount);//确认转账前，先验证转帐金额
	if(bool){
		var rollinAcc = $("#account-change").text();//转入卡号
		window.location.href="${base}/m/doTransfer?amount="+amount+"&rollinAcc="+rollinAcc;
	}
}
</script>

</html>